]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/network: Use connectObject() to connect client signals
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 31 Jul 2022 23:47:22 +0000 (01:47 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 7 Aug 2022 20:41:09 +0000 (22:41 +0200)
We would want the signals to be disconnected if we ever happened to
destroy the indicator. Even if we don't, connectObject() is simply
nicer when connecting half a dozen handlers at once.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>

js/ui/status/network.js

index db604be4d2509e750194708d150f8cfbccb67538..65e91b35e9fe191bf4038ca6d4eaa030add0416d 100644 (file)
@@ -1783,17 +1783,19 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._syncMainConnection();
         this._syncVpnConnections();
 
-        this._client.connect('notify::nm-running', this._syncNMState.bind(this));
-        this._client.connect('notify::networking-enabled', this._syncNMState.bind(this));
-        this._client.connect('notify::state', this._syncNMState.bind(this));
-        this._client.connect('notify::primary-connection', this._syncMainConnection.bind(this));
-        this._client.connect('notify::activating-connection', this._syncMainConnection.bind(this));
-        this._client.connect('notify::active-connections', this._syncVpnConnections.bind(this));
-        this._client.connect('notify::connectivity', this._syncConnectivity.bind(this));
-        this._client.connect('device-added', this._deviceAdded.bind(this));
-        this._client.connect('device-removed', this._deviceRemoved.bind(this));
-        this._client.connect('connection-added', this._connectionAdded.bind(this));
-        this._client.connect('connection-removed', this._connectionRemoved.bind(this));
+        this._client.connectObject(
+            'notify::nm-running', () => this._syncNMState(),
+            'notify::networking-enabled', () => this._syncNMState(),
+            'notify::state', () => this._syncNMState(),
+            'notify::primary-connection', () => this._syncMainConnection(),
+            'notify::activating-connection', () => this._syncMainConnection(),
+            'notify::active-connections', () => this._syncVpnConnections(),
+            'notify::connectivity', () => this._syncConnectivity(),
+            'device-added', this._deviceAdded.bind(this),
+            'device-removed', this._deviceRemoved.bind(this),
+            'connection-added', this._connectionAdded.bind(this),
+            'connection-removed', this._connectionRemoved.bind(this),
+            this);
 
         try {
             this._configPermission = await Polkit.Permission.new(